<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>服务记录</title>
	<meta name="decorator" content="default"/>
	<script src="${ctxStatic}/layer/layer.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnAdd").click(function(){
				var memberId=$("#memberId").val();
				var record=$("#record").val();
				if(!record){
					layer.alert("请输入服务记录",-1);
					return;
				}
				 $.ajax({  
                     type : "POST",  //提交方式  
                     url : "${ctx}/sys/servicerecord/serviceRecord/ajaxSave",//路径
                     data : {"member.id":memberId,"record":record},//数据，这里使用的是Json格式进行传输  
                     success : function(data) {//返回数据根据结果进行相应的处理  
                          if(data){
                          	layer.msg("操作成功",{time:500},function(){
                          		window.location.reload();
                          	});
                          }else{
                          	layer.msg("操作失败",{time:500});
                          }
                     }  
               });
			});
			$(".btn-add").click(function(){
				var id=$(this).data("id");
				if(!id){
					layer.msg("删除失败，请联系管理员",{time:500},-1);
					return;
				}	
				layer.confirm('确认要删除吗？', {
            	    btn: ['确认','取消'], //按钮
            	    shade: false //不显示遮罩
            	}, function(index){
            		 $.ajax({  
                         type : "POST",  //提交方式  
                         url : "${ctx}/sys/servicerecord/serviceRecord/ajaxDelete",//路径  
                         data : {"id":id},//数据，这里使用的是Json格式进行传输  
                         success : function(data) {//返回数据根据结果进行相应的处理  
                              if(data){
                              	layer.msg("操作成功,",{time:500},function(){
                              		window.location.reload();
                              	});
                              }else{
                              	layer.msg("操作失败",{time:500},-1);
                              }
                         }  
                   });
            	});
				
				
			});
			
			
		});
	</script>
</head>
<body>
<input type="hidden" id="memberId" value="${member.id}">
<div class="row" style="text-align: center;"><h2>【<c:if test="${member.realname != null}">${member.realname}</c:if><c:if test="${member.realname == null}">${member.nickname}</c:if>】的服务记录</h2></div>
	<div class="row" style="text-align: center;padding-top: 11px;">
		 <div class="col-md-2 col-md-offset-5" style="text-align: center;font-size:32px;overflow: hidden; ">
			 服务记录：<input id="record" type="text" style="width: 60%;height: 30px;"  class="input-xlarge required" />
			 <%--<shiro:hasPermission name="sys:member:member:sr:edit">--%>
			<input id="btnAdd" class="btn btn-danger" type="button" value="添加" />
			 <%--</shiro:hasPermission>--%>
		</div>
	</div>
	<div class="row" style="padding-left: 20px">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th style="width: 1%">序号</th>
				<th style="width: 10%">记录时间</th>
				<th style="width: 10%">记录人</th>
				<th style="width: 70%">服务记录</th>
				<shiro:hasPermission name="sys:member:member:sr:edit">
				<th style="width: 2%">操作</th>
				</shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:choose>
			<c:when test="${empty srList && fn:length(srList)==0 }">	<tr> <td colspan="5"><div class="col-md-2 col-md-offset-5" style="text-align: center;font-size:32px; line-height:550px; height: 550px;">暂无对该用户的服务记录 </div></td> </tr></c:when>
			<c:otherwise>
				<c:forEach items="${srList}" var="sr" varStatus="p">
				<tr>
					<td>${p.index+1}</td>
					<td>
						<fmt:formatDate value="${sr.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
					</td>
					<td>${sr.createBy.name}</td>
					<td>
						${sr.record}
					</td>
					<shiro:hasPermission name="sys:member:member:sr:edit">
					<td>
						<a href="#" class="btn-add" data-id="${sr.id }">删除</a>
					</td>
					</shiro:hasPermission>
				</tr>
				</c:forEach>
			</c:otherwise>
	    </c:choose>
		<c:forEach items="${page.list}" var="loan">
			
		</c:forEach>
		</tbody>
	</table>
	</div>
</body>
</html>